#include <iostream>
#include "mysql.h"
#include <string>

int main()
{
    //看数据库的版本号
    //std::cout << "version: " << mysql_get_client_info() << std::endl;
    
    MYSQL* conn = mysql_init(nullptr); //创建一个mysql句柄
    mysql_set_character_set(conn , "utf8");
    //连接套接字函数
    if (nullptr == mysql_real_connect(conn , "127.0.0.1" , "http_user" , "Qwer_13204556363" , "http_test" , 3306, nullptr , 0))
    {
        std::cerr << "connect error!" << std::endl;
        return 1;
    }

    std::cerr << "connect success" << std::endl;

    //在这里对数据进行处理
    std::string sql = "insert into user (name , password) values (\'李四\' , \'12345678\')";
    std::cerr << "query: " << sql << std::endl;

    int ret = mysql_query(conn , sql.c_str());

    std::cerr << "result: " << ret << std::endl;
    mysql_close(conn);
  
    return 0;
}



